<template>
	<view>
		<view v-if="swiperList.length>0" style="margin-top: 40rpx;">
			<u-swiper :list="swiperList" previousMargin="30" nextMargin="30" circular :autoplay="false" radius="5"
				bgColor="#f5f5f5" :height="windowHeight" @click="clickSwiper" imgMode="heightFix"></u-swiper>
		</view>
		<view v-else>
			<image  style="width: 750rpx;height: 1644rpx;" :src="find_placeholder" mode="widthFix"></image>
		</view>

		<HomeTabbar :tab="1"></HomeTabbar>
	</view>
</template>

<script>
	import HomeTabbar from '@/components/tabbar/tabbar';
	import couponItem from '@/components/coupon/coupon-item.vue'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import settings from '@/settings.js'
	import {
		apiActivityCarouseArea,
		apiActivityListArea
	} from '@/api/activity-api.js'
	export default {
		mixins: [MescrollMixin], // 使用mixin
		components: {
			HomeTabbar,
		},
		data() {
			return {
				swiperList: [],
				windowHeight : 0,
				find_placeholder : 'https://qykh.shopec.com.cn/image-server/dz/find_placeholder.png'
			}
		},
		onLoad() {
			
			wx.showShareMenu({
				withShareTicket: true,
				menus: ['shareAppMessage']
			})
			this.getCarouseData();
			this.windowHeight = uni.getSystemInfoSync().windowHeight - 100;
			if(settings.tenantId == '93') {//丰田
				this.find_placeholder = 'https://qykh.shopec.com.cn/image-server/dz/fentian/find_placeholder.png'
			}
		},
		computed: {
			isLogin() {
				return this.$store.state.user.isLogin;
			}
		},
		methods: {

			// 获取轮播图卡片
			getCarouseData() {
				apiActivityCarouseArea({
					tenantId: this.$store.state.user.tenantId
				}).then(res => {
					let data = res.data;
					this.swiperActivityList = data;
					data.forEach(item => {
						let url = settings.baseImageUrl + item.coverPictures;
						this.swiperList.push(url);
					})

				})
			},

			clickSwiper(index) {
				let activityItem = this.swiperActivityList[index];
				this.configTemplateView(activityItem);

			},
			// 配置活动模板
			configTemplateView(activityItem) {
				let templateCode = activityItem.templateCode;
				switch (templateCode) {
					case 'YHQ-001': //优惠券模板
						uni.navigateTo({
							url: '/pagesB/activity/template/coupon?activityId=' + activityItem.activityId
						})
						break;
					case 'CX-001': //车型模板
						uni.navigateTo({
							url: '/pagesB/activity/template/car?activityId=' + activityItem.activityId
						})
						break;
					case 'ZQ-CX-001': //中秋节车型模板
						uni.navigateTo({
							url: '/pagesB/activity/template/zhongqiu-car?activityId=' + activityItem.activityId
						})
						break;
					case 'ZQ-SQ-001': //中秋节优惠券模板
						uni.navigateTo({
							url: '/pagesB/activity/template/zhongqiu-coupon?activityId=' + activityItem.activityId
						})
						break;
					default:
						break;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.couponContent {
		margin: 20rpx;
	}
</style>
